const rtrurnCode = require("../utils/index")
class Index {
    static async MeiTanChanLiang(ctx) {
        const data = [{ type: '日', info: { jihua: 5.5, shiji: 5, jindu: 10, tb1: 10, tb2: 12 }, chart: [{ type: 'jihua', data: [4, 4, 4, 4, 4, 4, 4, 4, 4, 4] }, { type: 'shiji', data: [12, 3, 4, 14, 11, 5, 7, 8, 9, 12] }] }, { type: '月', info: { jihua: 5.6, shiji: 6, jindu: 15, tb1: 16, tb2: 13 }, chart: [{ type: 'jihua', data: [5, 4, 5, 4, 5, 4, 7, 4, 3, 4] }, { type: 'shiji', data: [11, 7, 2, 1, 11, 15, 7, 6, 9, 4] }] }, { type: '年', info: { jihua: 3.5, shiji: 5.7, jindu: 9, tb1: 12, tb2: 17 }, chart: [{ type: 'jihua', data: [8, 8, 5, 5, 4, 4, 2, 2, 6, 7] }, { type: 'shiji', data: [9, 13, 14, 4, 1, 15, 12, 7, 4, 8] }] }]
        ctx.body = rtrurnCode(data)
    }

    static async JueJinJinChi(ctx) {
        const data = [{ type: '日', info: { jihua: 2.4, shiji: 3.5, jindu: 3.3, tb1: 23.1, tb2: 32 }, chart: [{ type: 'jihua', data: [5, 4, 5, 4, 5, 4, 5, 4, 5, 4] }, { type: 'shiji', data: [12, 3, 4, 14, 11, 5, 7, 8, 9, 12] }] }, { type: '月', info: { jihua: 5.6, shiji: 6, jindu: 15, tb1: 16, tb2: 13 }, chart: [{ type: 'jihua', data: [5, 6, 5, 4, 7, 4, 8, 4, 9, 4] }, { type: 'shiji', data: [11, 7, 2, 1, 11, 15, 7, 6, 9, 4] }] }, { type: '年', info: { jihua: 3.5, shiji: 5.7, jindu: 9, tb1: 12, tb2: 17 }, chart: [{ type: 'jihua', data: [8, 2, 5, 5, 6, 4, 8, 8, 6, 7] }, { type: 'shiji', data: [9, 13, 14, 4, 1, 15, 12, 7, 4, 8] }] }]
        ctx.body = rtrurnCode(data)
    }

    static async MeiTanCangChu(ctx) {
        const data = [{
            type: '仓储量',
            mdky: 8.5,
            ydky: 7.3,
            nlky: 6.5,
            jtky: 5.4,
            hlky: 4.2,
            mkqky: 3.6,
        }, {
            type: '销量',
            mdky: 2.5,
            ydky: 3.3,
            nlky: 4.5,
            jtky: 5.4,
            hlky: 6.2,
            mkqky: 7.6,
        }]
        ctx.body = rtrurnCode(data)
    }

    static JingXiaRenYuan(ctx) {
        const data = [{ type: '日', data: [20, 33, 44, 11, 22, 33, 45, 67] }, { type: '月', data: [24, 13, 14, 31, 12, 23, 15, 17] }, { type: '年', data: [333, 444, 544, 200, 400, 100, 86, 700] }]
        ctx.body = rtrurnCode(data)
    }


    static ShuJuShangChuanJianCe(ctx) {
        function generateDynamicData(template, count = 100000) {
            // 煤矿名称列表
            const mineNames = [
                "轩岗煤矿", "大同煤矿", "阳泉煤矿", "晋城煤矿", "潞安煤矿",
                "西山煤矿", "汾西煤矿", "霍州煤矿", "晋中煤矿", "吕梁煤矿"
            ];

            // 系统名称列表
            const systemNames = [
                "环境监测系统", "安全监控系统", "生产管理系统",
                "人员定位系统", "设备管理系统", "瓦斯监测系统"
            ];

            // 状态列表
            const statuses = ["运行中", "维护中", "已停用", "调试中", "故障"];

            // 用户列表
            const users = [
                "王十二", "张三", "李四", "王五", "赵六",
                "钱七", "孙八", "周九", "吴十", "郑十一"
            ];

            const result = [];
            const startTime = new Date('2023-01-01').getTime();
            const endTime = new Date('2023-12-31').getTime();

            for (let i = 0; i < count; i++) {
                // 随机选择各项数据
                const randomMine = mineNames[Math.floor(Math.random() * mineNames.length)];
                const randomSystem = systemNames[Math.floor(Math.random() * systemNames.length)];
                const randomStatus = statuses[Math.floor(Math.random() * statuses.length)];
                const randomUser = users[Math.floor(Math.random() * users.length)];

                // 随机生成维护时间(1-300分钟)
                const randomJgTime = `${Math.floor(Math.random() * 300) + 1}分钟`;

                // 随机生成时间戳
                const randomTimestamp = new Date(startTime + Math.random() * (endTime - startTime));
                const randomLoadTime = randomTimestamp.toISOString().replace('T', ' ').substring(0, 19);

                // 创建新对象
                const newObj = {
                    mkname: randomMine,
                    sysname: randomSystem,
                    status: randomStatus,
                    jgtime: randomJgTime,
                    loadtime: randomLoadTime,
                    users: randomUser
                };

                result.push(newObj);
            }

            return result;
        }

        // 使用示例
        const template = {
            mkname: "轩岗煤矿",
            sysname: "环境监测系统",
            status: "维护中",
            jgtime: "75分钟",
            loadtime: "2023-05-15 18:40:00",
            users: "王十二",
        };

        const dynamicData = generateDynamicData(template, 100000);
        ctx.body = rtrurnCode(dynamicData)
    }


}
module.exports = Index